package com.frost.demo.ioc.controller;

import com.frost.demo.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
    // 属性注入
//    @Autowired
//    private UserService userService;
    // 构造器注入
//    private UserService userService;
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }
    // set 方法注入
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void say() {
        System.out.println("hi,controller");
        userService.say();
    }
}
